public class Demo2 {
    public int findMinimum(int n, int[] left, int[] right) {
        int leftSum = 0;
        int rightSum = 0;
        int leftmin = Integer.MAX_VALUE;
        int rightmin = Integer.MAX_VALUE;
        int sum =0;

        for(int i = 0; i < n; i++) {
            if(left[i] * right[i] == 0) {
                sum += left[i] + right[i];
            }else {
                leftSum += left[i];
                rightSum += right[i];
                if(leftmin > left[i]) {
                    leftmin = left[i];
                }

                if(rightmin > right[i]) {
                    rightmin = right[i];
                }
            }
        }

        return Math.min(leftSum - leftmin + 1,rightSum - rightmin + 1) + sum + 1;
    }
    public static void main(String[] args) {

    }
}
